package javazuoye;

/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/07/02 16:24
 */
public class TestStringBuf {
    public static void main(String argS[]) {
        StringBuffer sb1 = new StringBuffer();
        StringBuffer sb2 = new StringBuffer(15);
        char cArray[] = new char[20];
        int i;
        sb1.append("Are you empty?");
        sb1.append("Why?");
        try {
            sb1.getChars(4, sb1.length() - 4, cArray, 0);
            System.out.println(cArray);
        } catch (ArrayIndexOutOfBoundsException e) {
        }
        try {
            for (i = 0; i < cArray.length; i++) {
                if (cArray[i] > 'm')
                    sb2.insert(i++, cArray[i]);
            }
        } catch (ArrayIndexOutOfBoundsException e) {
        }
        System.out.println(sb1);
        System.out.println(sb2);
    }
}
